package club.babyf.nativeai.common.exception;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.http.HttpStatus;

import java.time.LocalDateTime;

/**
 * BaseException.
 *
 * @author zhanglei.
 * @date 2025/2/21 15:44.
 * @description API错误返回格式.
 */
@Data
public class BaseException {

    private int code = HttpStatus.BAD_REQUEST.value();

    private String message;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime time;

    public BaseException() {
        time = LocalDateTime.now();
    }

    public BaseException(String message) {
        this.message = message;
        time = LocalDateTime.now();
    }

    public BaseException(String message, int code) {
        this.message = message;
        this.code = code;
        time = LocalDateTime.now();
    }

}
